import {
  RouterProvider,
  createBrowserRouter,
} from "react-router-dom";
import App from '@/App'
import React from "react";


const Page404 = React.lazy(() => import('@/gui/404/main'))

const withLoadingComponent = (component: React.ReactNode) => {
  return <React.Suspense fallback={<h2>🌀 加载中...</h2>}>{ component }</React.Suspense>
}



const routes = [
  {
    path: '/',
    element: <App></App>,
  },
  {
    path: '*',
    element: withLoadingComponent(<Page404></Page404>),
  },
]

const router = createBrowserRouter(routes, {
  future: {
    v7_normalizeFormMethod: true,
  }
});

export default <RouterProvider router={router} />;